package com.zcx.excel.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
/**
 * @author zhaochangxin
 * @Title: SwaggerConfig
 * @Package com.zcx.exceldemo.config
 * @Description: SwaggerConfig
 * @date 2022/3/25 10:42
 */
public class SwaggerConfig {

    @Value("${swagger2.enable}")
    private boolean enable;
    @Bean
    public Docket createDocke(){
        return new Docket(DocumentationType.SWAGGER_2)
                // 进入swagger-ui的信息
                .apiInfo(apiInfo())
                .select()
                // 为当前配置的包下controller生成API文档
                .apis(RequestHandlerSelectors.basePackage("com.zcx.excel.controller"))
                .paths(PathSelectors.any())
                .build()
                .enable(enable);
    }
    // 进入swagger-ui的信息
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                // 该项目的名字
                .title("登陆测试")
                // 该项目的描述
                .description("userLogin")
                .version("1.0")
                .build();
    }
}
